package org.whuims.expertreader.entity;

import javax.persistence.*;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;

/**
 * @author Qikai Cheng
 * @date 五月 07 2018
 */
@Table(name = "topic")
@Entity
public class Topic {
    @Id
    private Integer id;
    private String label;

    private String name;

    @Transient
    private String longName;

    @OneToMany(fetch = FetchType.LAZY, mappedBy = "topic")
    private List<Paper> paperList = new ArrayList<Paper>();

    @ManyToOne
    @JoinColumn(name = "parentId")
    private Topic parent;

    @OneToMany(mappedBy = "parent", cascade = CascadeType.ALL, fetch = FetchType.LAZY)
    private Set<Topic> children = new HashSet<Topic>();

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = (id);
    }

    public String getLabel() {
        return label;
    }

    public void setLabel(String label) {
        this.label = (label);
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = (name);
    }

    public List<Paper> getPaperList() {
        return paperList;
    }

    public void setPaperList(List<Paper> paperList) {
        this.paperList = (paperList == null ? null : paperList);
    }

    public Topic getParent() {
        return parent;
    }

    public void setParent(Topic parent) {
        this.parent = parent;
    }

    public Set<Topic> getChildren() {
        return children;
    }

    public void setChildren(Set<Topic> children) {
        this.children = children;
    }
}
